From 8ec1bc1a789d26c9db2c39cd6c7af1f2f7e926f5 Mon Sep 17 00:00:00 2001 From: "iap10@labyrinth.cl.cam.ac.uk" Date: Thu, 12 Aug 2004 07:24:06 +0000 Subject: [PATCH] bitkeeper revision 1.1159.17.14 (411b1b16kI8OhQTxCf1kbM8dV6LXcA) prepare 2.6 blkfront for suspend/resume --- linux-2.6.7-xen-sparse/drivers/char/mem.c | 2 +- .../drivers/xen/blkfront/blkfront.c | 71 +++++++++++++++---- tools/misc/xen-clone | 2 +- 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/linux-2.6.7-xen-sparse/drivers/char/mem.c b/linux-2.6.7-xen-sparse/drivers/char/mem.c index 5dba3aee46..ceea2b5ffd 100644 --- a/linux-2.6.7-xen-sparse/drivers/char/mem.c +++ b/linux-2.6.7-xen-sparse/drivers/char/mem.c @@ -252,7 +252,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma) vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); if (direct_remap_area_pages(vma->vm_mm, vma->vm_start, offset, vma->vm_end-vma->vm_start, vma->vm_page_prot, - (domid_t)file->private_data)) + (domid_t)(unsigned long)file->private_data)) return -EAGAIN; return 0; } diff --git a/linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c index 9d326f6a35..da7aa2bfe6 100644 --- a/linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6.7-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -50,6 +50,32 @@ static int recovery = 0; /* "Recovery in progress" flag. Protected static request_queue_t *pending_queues[MAX_PENDING]; static int nr_pending; +inline void translate_req_to_pfn( blkif_request_t * xreq, blkif_request_t * req) +{ + int i; + + *xreq=*req; + for ( i=0; inr_segments; i++ ) + { + xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) | + (machine_to_phys_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<nr_segments; i++ ) + { + xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) | + (phys_to_machine_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req = - *ring_req; + translate_req_to_pfn( + &blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req, + ring_req); + blk_ring_rec->req_prod++; return 0; @@ -407,9 +435,10 @@ void blkif_control_send(blkif_request_t *req, blkif_response_t *rsp) goto retry; } - memcpy(&blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req, req, sizeof(*req)); - memcpy(&blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req, - req, sizeof(*req)); + blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req = *req; + translate_req_to_pfn(&blk_ring_rec->ring[ + MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req,req); + req_prod++; flush_requests(); @@ -497,9 +526,9 @@ static void blkif_status_change(blkif_fe_interface_status_changed_t *status) if ( recovery ) { - int i; + int i,j; - /* Shouldn't need the blkif_io_lock here - the device is + /* Shouldn't need the io_request_lock here - the device is * plugged and the recovery flag prevents the interrupt handler * changing anything. */ @@ -507,18 +536,24 @@ static void blkif_status_change(blkif_fe_interface_status_changed_t *status) for ( i = 0; resp_cons_rec < blk_ring_rec->req_prod; resp_cons_rec++, i++ ) - { - blk_ring->ring[i].req - = blk_ring_rec->ring[MASK_BLKIF_IDX(resp_cons_rec)].req; + { + translate_req_to_mfn(&blk_ring->ring[i].req, + &blk_ring_rec->ring[ + MASK_BLKIF_IDX(resp_cons_rec)].req); } - /* Reset the private block ring to match the new ring. */ - memcpy(blk_ring_rec, blk_ring, sizeof(*blk_ring)); + /* Reset the private block ring to match the new ring. */ + for( j=0; jring[j].req, + &blk_ring->ring[j].req); + } + resp_cons_rec = 0; /* blk_ring->req_prod will be set when we flush_requests().*/ blk_ring_rec->req_prod = req_prod = i; - wmb(); /* Switch off recovery mode, using a memory barrier to ensure that @@ -677,4 +712,14 @@ void blkdev_suspend(void) void blkdev_resume(void) { + ctrl_msg_t cmsg; + blkif_fe_driver_status_changed_t st; + + /* Send a driver-UP notification to the domain controller. */ + cmsg.type = CMSG_BLKIF_FE; + cmsg.subtype = CMSG_BLKIF_FE_DRIVER_STATUS_CHANGED; + cmsg.length = sizeof(blkif_fe_driver_status_changed_t); + st.status = BLKIF_DRIVER_STATUS_UP; + memcpy(cmsg.msg, &st, sizeof(st)); + ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE); } diff --git a/tools/misc/xen-clone b/tools/misc/xen-clone index 392bf8c6fe..ce650f5dd8 100755 --- a/tools/misc/xen-clone +++ b/tools/misc/xen-clone @@ -72,7 +72,7 @@ then make -j4 world make -j4 linux26 cd ../install/boot - [ -r vmlinuz-${LINUX_VER}-xen0 ] && ln -s vmlinuz-${LINUX_VER}-xen0 xenolinux.gz + [ -r vmlinuz-2.4.*-xen0 ] && ln -s vmlinuz-2.4.*-xen0 xenolinux.gz else # old style repository without 'make world' -- 2.30.2